#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <pthread.h>

struct ClientData
{
    /* data */
    struct sockaddr_in server;
    int PORT;
    char *AddressIP;
    int client_fd;
} ClientData;

int main(int argc,char **argv)
{
    ClientData.client_fd = socket(PF_INET, SOCK_DGRAM, 0);
    if (ClientData.client_fd < 0) {
        perror("socket");
        return -1;
    }
    ClientData.server.sin_family = AF_INET;
    ClientData.server.sin_port   = htons(atoi(argv[2]));
    inet_pton(AF_INET, argv[1], &ClientData.server.sin_addr.s_addr);
    while (1) {
        char buf[100] = {'\0'};
        printf("send buf : ");
        gets(buf);
        sendto(ClientData.client_fd, buf, strlen(buf), 0, (struct sockaddr *)&ClientData.server, sizeof(ClientData.server));
    }
    close(ClientData.client_fd);
    return 0;
}